package com.tkk.monitoring.analyze.http;

import io.netty.handler.codec.http.HttpHeaders;
import org.apache.http.client.methods.CloseableHttpResponse;

import java.util.Map;

/**
 * author: Tkk
 * date: 2015/7/8
 */
public class Session extends Request {

    private HttpHeaders headers;
    private String uri;
    private String method;

    public Session(String uri, String method, HttpHeaders headers) {
        super();
        this.uri = uri;
        this.method = method;
        this.headers = headers;
    }

    public Session setUri(String uri) {
        this.uri = uri;
        return this;
    }

    public String content(Map<String, Object> paramMap) {
        if (method.equals("get")) {
            return getContent(this.uri, paramMap, headers);
        } else {
            return postContent(this.uri, paramMap, headers);
        }
    }

    public CloseableHttpResponse response(Map<String, Object> paramMap) {
        if (method.equals("get")) {
            return getResponse(this.uri, paramMap, headers);
        } else {
            return postResponse(this.uri, paramMap, headers);
        }
    }
}
